package br.com.onlinebidding.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(schema = "db_onlinebidding", name = "Product")
@NamedQuery(name = "Product.findAllProductNotUse", query = "SELECT p FROM Product p where p.inUse = :inUse")
public class Product implements Serializable{

	public static final String FIND_BY_PRODUCTS_NOT_USE = "Product.findAllProductNotUse";
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	private String name;
	private String description;
	private boolean inUse;
	
	public int getId() {return id;}
	public void setId(int id) {this.id = id;}
	
	public String getName() {return name;}
	public void setName(String name) {this.name = name;}
	
	public String getDescription() {return description;}
	public void setDescription(String description) {this.description = description;}
	
	public boolean isInUse() {return inUse;}
	public void setInUse(boolean inUse) {this.inUse = inUse;}
	
	@Override
	public int hashCode() {return getId();}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Product) {
			 Product  product = ( Product) obj;
			return  product.getId() == this.id;}
		return false;
	}
}
